Comparison between the microbiota states for the ages and sexes
Table of content
Generated from a Jupyter Notebook - Sources
source("load_libraries.R")
source("functions.R")
load("../results/dge/gene_length.RData")
load("../results/dge/filtered_metadata.RData")
load("../results/dge/dge.RData")
load("../results/dge/contrasts.RData")
load("../results/dge/filtered_norm_counts.RData")
load("../results/dge/filtered_z_scores.RData")
load("../results/dge/dge_net_pal2.RData")
load("../results/dge/col_order.RData")
load("../results/dge/annot_col.RData")
load("../results/dge/annot_colors.RData")
load("../results/dge/genes_in_modules.RData")
load("../results/dge/all_deg_genes.RData")
dir_path = "microbiota-effect/microbiota-sex-age/"
Extract DEG between GF and SPF for the different ages and sex combinations
Table with the factors
sub_contrasts = contrasts %>%
filter(Info == 'GF vs SPF (Female, Young)' |
Info == 'GF vs SPF (Male, Young)' |
Info == 'GF vs SPF (Female, Middle-aged)' |
Info == 'GF vs SPF (Male, Middle-aged)' |
Info == 'GF vs SPF (Female, Old)' |
Info == 'GF vs SPF (Male, Old)')
sub_contrasts
deg_results = lapply(sub_contrasts$Info, function(x) get_dge_results(x, dge, sub_contrasts))
names(deg_results) = sub_contrasts$Info
Extract the log2FC of the DEG
deg = extract_DEG_log2FC(deg_results, dir_path)
all_deg_genes = unique(c(all_deg_genes, deg$sign_fc_deg$genes))
save(all_deg_genes, file="../results/dge/all_deg_genes.RData")
deg = extract_DEG_stats(deg, dir_path)
deg$stat
All DEG (Wald padj < 0.05)
plot_sign_DEG_upset(deg)
DEG (Wald padj < 0.05 & abs(FC) > 1.5)
pdf(paste('../results/dge/', dir_path, '/sign_FC_DEG_upset.pdf', sep=''))
plot_sign_FC_DEG_upset(deg)
dev.off()
plot_sign_FC_DEG_upset(deg)
data = deg$sign_fc_deg %>% select(-genes)
fc_annot = data.frame(Comparison = rep("GF VS SPF",2),
Sex = rep(c("Female","Male"), 3),
Age = c(rep("Young", 2), rep("Middle-aged", 2), rep("Old", 2)),
row.names = colnames(data))
fc_annot
plot_fc_heatmap(data, fc_annot)
comps = list(
"GF vs SPF (Female, Young)" = c(grep("SPF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"GF vs SPF (Female, Middle-aged)" = c(grep("SPF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"GF vs SPF (Female, Old)" = c(grep("SPF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"GF vs SPF (Male, Young)" = c(grep("SPF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"GF vs SPF (Male, Middle-aged)" = c(grep("SPF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"GF vs SPF (Male, Old)" = c(grep("SPF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE))
)
plot_z_score_heatmap(z_scores,
deg$sign_fc_deg$genes,
col_order$sam,
annot_col$sam,
"All DE genes in GF vs SPF for any sex and age",
col_order$sam)
pdf(paste('../results/dge/', dir_path, '/z_score_sam.pdf', sep=''))
plot_z_score_heatmap(z_scores,
deg$sign_fc_deg$genes,
col_order$sam,
annot_col$sam,
"All DE genes in GF vs SPF for any sex and age",
col_order$sam)
dev.off()
for(comp in names(comps)){
plot_z_score_heatmap(z_scores,
deg$sign_fc_deg %>% filter(!is.na((!!as.name(comp)))) %>% pull(genes),
col_order$sam,
annot_col$sam,
paste("DE genes in", comp),
comps[[comp]])
}
plot_z_score_heatmap(z_scores,
deg$sign_fc_deg$genes,
col_order$asm,
annot_col$asm,
"All DE genes in GF vs SPF for any sex and age",
col_order$asm)
pdf(paste('../results/dge/', dir_path, '/z_score_asm.pdf', sep=''))
plot_z_score_heatmap(z_scores,
deg$sign_fc_deg$genes,
col_order$asm,
annot_col$asm,
"All DE genes in GF vs SPF for any sex and age",
col_order$asm)
dev.off()
for(comp in names(comps)){
plot_z_score_heatmap(z_scores,
deg$sign_fc_deg %>% filter(!is.na((!!as.name(comp)))) %>% pull(genes),
col_order$asm,
annot_col$asm,
paste("DE genes in", comp),
comps[[comp]])
}
comps = names(comps)
plot_z_score_heatmap_with_modules(z_scores,
rownames(z_scores),
col_order$sam,
annot_col$sam,
genes_in_modules,
"All genes")
for(comp in comps){
plot_z_score_heatmap_with_modules(z_scores,
deg$sign_fc_deg %>% filter(!is.na((!!as.name(comp)))) %>% pull(genes),
col_order$sam,
annot_col$sam,
genes_in_modules,
paste("DE genes in", comp))
}
plot_z_score_heatmap_with_modules(z_scores,
rownames(z_scores),
col_order$asm,
annot_col$asm,
genes_in_modules,
"All genes")
for(comp in comps){
plot_z_score_heatmap_with_modules(z_scores,
deg$sign_fc_deg %>% filter(!is.na((!!as.name(comp)))) %>% pull(genes),
col_order$asm,
annot_col$asm,
genes_in_modules,
paste("DE genes in", comp))
}
for(comp in comps){
plot_top_deg_in_modules(deg$sign_fc_deg, comp, genes_in_modules)
}
options(repr.plot.width=7, repr.plot.height=7)
deg = fit_proba_weighting_function(deg, gene_length)
deg = extract_GO_terms(deg, dir_path)
Dot-plot with the 10 most significant p-values for the different comparison
plot_top_go(deg, "BP", 10)
Dot-plot with the most over-represented CC GO (20 most significant p-values for the different comparison)
plot_top_go(deg, "CC", 10)
Dot-plot with the most over-represented MF GO (20 most significant p-values for the different comparison)
plot_top_go(deg, "MF", 10)
The edge colors in the tree represent the relationship between two nodes. - green: positively regulates
GO Trees at "../results/dge/microbiote-effect/microbiote-sex-age/go/"
for(comp in comps){
print(comp)
fn = gsub(' ', '_', comp)
fn = gsub('(\\(|\\)|,)', '', fn)
fp = paste('../results/dge/', dir_path, 'go/', fn, '.png', sep='')
col = get_GO_network_col_all_ont(deg$GO, comp)
dotRes = getAmigoTree(goIDs=col$category,
color=col$color,
filename=fp,
picType="png",
saveResult=TRUE)
}
deg = extract_KEGG_pathways(deg, dir_path)
plot_kegg_pathways(deg$KEGG$over$category,
deg$sign_fc_deg,
paste('../results/dge/', dir_path, '/kegg/over_repr_kegg/', sep=''))
Pathway graphs available at ../results/dge/type-effect/type_gender_age/over_repr_kegg/
plot_kegg_pathways(deg$under_represented_KEGG[,"category"],
deg$fc_deg,
paste('../results/dge/', dir_path, '/kegg/under_repr_kegg/', sep=''))
Pathway graphs available at ../results/dge/type-effect/type_gender_age/under_repr_kegg/
citation("pheatmap")
citation("RamiGO")
citation("pathview")